<template>
  <!-- 列表切换框组件 -->
  <view class="nav">
    <view class="nav__list">
      <view
              v-for="item in means"
              :key="item.id"
              class="nav__item"
              @tap="handleChange(item)">
        <view class="nav__li">
          <view class="nav__tit" :style="{fontWeight:select === item.id?'600':''}">{{item.name}}</view>
          <img class="nav__line" v-if="select === item.id" :src="icon_line"/>
        </view>
      </view>
    </view>
    <view class="nav_btn" v-if="chaper_sections===50" @click="handleClick">添加笔记</view>
    <view>
      <slot></slot>
    </view>
  </view>
</template>

<script>
/**
 * lessonCatalog 菜单组件 （未完成,需要业务支持）
 * @property {Array} means 菜单的数据列
 * @property {Number} select 当前的选择项下标
 */
export default {
  name: "lesson-catalog",
  model: {
    prop: "chaper_sections",
    event: "change"
  },
  data() {
    return {
      // select: 10
    };
  },
  props: {
    chaper_sections: {
      type: Number,
      default: 10
    },
    icon_line:{
      type: String,
      default: '/static/img-skin/index/icon_line.png'
    },
    select: {
      type: Number,
      default: 10
    },
    means: {
      type: Array,
      default() {
        return [
          { name: "视频", id: 10 },
          { name: "讲义", id: 20 }
          //   { name: "练习", id: 30 }
        ];
      }
    }
  },
  methods: {
    handleChange(item) {
      this.$emit("change", item.id);
      // this.select = item.id
    },
    handleClick() {
      this.$emit("addNote");
    }
  }
};
</script>

<style lang="scss" scope>
.nav {
  position: relative;
  .nav__list {
    display: flex;
    height: 60rpx;
    margin-bottom: 40rpx;
    .nav__item {
      display: flex;
      color: #666;
      font-size: 32rpx;
      margin-right: 61rpx;
      padding-bottom: 20rpx;
      .nav__li{
        display: flex;
        flex-direction: column;
        align-items: center;
        .nav__tit{
          margin-bottom: 6rpx;
        }
        .nav__line{
          display: flex;
          width: 28rpx;
          height: 18rpx;
          text-align: center;
        }
      }
    }
  }
  .nav_btn {
    position: absolute;
    right: 0;
    top: 10rpx;
    border-radius: 10rpx;
    background-color: rgb(22, 155, 213);
    color: #fff;
    padding: 10rpx;
  }
}
</style>
